/**
 *
 *
 */
package com.fw.timesheet.service;


import java.util.List;

import com.fw.timesheet.dao.EmployeeDAO;
import com.fw.timesheet.model.Employee;



/**
 * @author sigit <br>
 * @version 1.0 <br>
 * Application : timesheet <br>
 * Copyright (c) fastwire-group 2012 <br>
 * <br>
 */
public class EmployeeService extends BaseService {

	private EmployeeDAO employeeDAO;

	public EmployeeDAO getEmployeeDAO() {
		return employeeDAO;
	}

	public void setEmployeeDAO(EmployeeDAO employeeDAO) {
		this.employeeDAO = employeeDAO;
		setDaoObject(employeeDAO);
	}
	
	
	
	public void delete(Employee persistentInstance) {
		getEmployeeDAO().delete(persistentInstance);
	}
	
	public Employee findById(Long id) {
		return getEmployeeDAO().findById(id);
	}
	
	/**
	 * find user password
	 * Password use name as password
	 * @param username
	 * @return
	 */
	public Employee findByUsername(String username) {
		Employee user = null;
		List<Employee> users = this.employeeDAO.findByUsername(username);
		if (users != null && users.size() == 1) {
			user = (Employee) users.get(0);
		}
		return user;
	}
	
}
